/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package serveur;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;
import shared.Processus;

/**
 *
 * @author xarckane
 */
public class ProcessusImpl extends UnicastRemoteObject implements Processus {

    private static ProcessusImpl instance;
    private static Object mutex = new Object();
    private ArrayList<shared.Process> process;

    private ProcessusImpl() throws RemoteException {
        
    }

    public static ProcessusImpl getInstance() throws RemoteException {
        if (null == instance) { // Premier appel
            synchronized (mutex) {
                if (null == instance) {
                    instance = new ProcessusImpl();
                }
            }
        }
        return instance;
    }

    @Override
    public String toString() {
        return "Processus : toto";
    }

    @Override
    public ArrayList<shared.Process> getprocess() throws RemoteException {
        this.process = new ArrayList<>();
        this.process.add(new shared.Process("toto", 201));
        this.process.add(new shared.Process("totio", 202));
        this.process.add(new shared.Process("titi", 203));
        return this.process;
    }
}
